package com.app.service.Impl;

import com.app.mapper.DaMeiSuZhouMapper;
import com.app.mapper.MotionVideoMapper;
import com.app.model.MotionVideoModel;
import com.app.service.DaMeiSuZhouService;
import com.app.vo.VideoVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DaMeiSuZhouServiceImpl implements DaMeiSuZhouService{


    @Autowired
    DaMeiSuZhouMapper daMeiSuZhouMapper;


    @Override
    public VideoVo getDaMeiSuZhouList(Integer page, Integer limit, String keyword, Integer type, Integer videoType) {
        VideoVo vo = new VideoVo();
        page = (page - 1) * limit;

        List<MotionVideoModel> daMeiSuZhouList = daMeiSuZhouMapper.getDaMeiSuZhouList(page, limit, keyword, type,videoType);
        for (MotionVideoModel motionVideoModel : daMeiSuZhouList) {
            if (motionVideoModel.getType() != null && motionVideoModel.getType() == 1){
                motionVideoModel.setTypeText("视频");
            }else if (motionVideoModel.getType() != null && motionVideoModel.getType() == 2){
                motionVideoModel.setTypeText("图文");
            }
        }

        int count = daMeiSuZhouMapper.getDaMeiSuZhouCount(keyword, type,videoType);
        vo.setList(daMeiSuZhouList);
        vo.setCount(count);
        return vo;
    }

    @Override
    public void update(MotionVideoModel model) {
        daMeiSuZhouMapper.updateById(model);
    }

    @Override
    public void insert(MotionVideoModel model) {
        daMeiSuZhouMapper.insert(model);
    }
}
